home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex19.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  578 b   |  27 lines

  1. Program ex19;
  2.  
  3. { Program to demonstrate the TStream.CopyFrom function }
  4.  
  5. Uses objects;
  6.  
  7. Var P : PString;
  8.     L : String;
  9.     S1,S2 : PStream;
  10.     
  11. begin
  12.   L:='Constant string line';
  13.   Writeln ('Writing to stream 1 : "',L,'"');
  14.   S1:=New(PMemoryStream,Init(100,10));
  15.   S2:=New(PMemoryStream,Init(100,10));
  16.   S1^.WriteStr(@L);
  17.   S1^.Seek(0);
  18.   Writeln ('Copying contents of stream 1 to stream 2');
  19.   S2^.Copyfrom(S1^,S1^.GetSize);
  20.   S2^.Seek(0);
  21.   P:=S2^.ReadStr;
  22.   L:=P^;
  23.   DisposeStr(P);
  24.   Dispose (S1,Done);
  25.   Dispose (S2,Done);
  26.   Writeln ('Read from stream 2 : "',L,'"');
  27. end.